package net.xo68.destiny.manager.config;

import net.xo68.destiny.core.eventbus.EventBusConfigurer;
import net.xo68.destiny.core.eventbus.EventHandleRouting;
import net.xo68.destiny.manager.eventHandle.JobStateReportEventHandle;
import net.xo68.destiny.manager.eventHandle.NodeDownlineEventHandle;
import net.xo68.destiny.manager.eventHandle.NodeRegistryEventHandle;
import net.xo68.destiny.starter.manager.enums.MessageEventTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

/**
 * 事件巴士配置
 * @author wuxie
 * @version 2020-11-14
 */
@Configuration
public class EventBusConfig implements EventBusConfigurer {

    @Autowired
    private NodeRegistryEventHandle nodeRegistryEventHandle;
    @Autowired
    private NodeDownlineEventHandle nodeDownlineEventHandle;
    @Autowired
    private JobStateReportEventHandle jobStateReportEventHandle;

    @Override
    public void configure(EventHandleRouting eventHandleRouting) {
        eventHandleRouting.put(MessageEventTypeEnum.NODE_REGISTRY.getCode(), this.nodeRegistryEventHandle);
        eventHandleRouting.put(MessageEventTypeEnum.NODE_DOWNLINE.getCode(), this.nodeDownlineEventHandle);
        eventHandleRouting.put(MessageEventTypeEnum.JOB_STATE_REPORT.getCode(), this.jobStateReportEventHandle);
    }
}
